FROM debian:7.8

ENV PG_MAJOR 9.4

# set apt-get key
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8

# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN apt-get update && apt-get install -y locales procps && rm -rf /var/lib/apt/lists/* \
    && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8

# install postgres
RUN apt-get update -y && apt-get install --no-install-recommends -y -q\
    postgresql-$PG_MAJOR postgresql-client-$PG_MAJOR postgresql-contrib-$PG_MAJOR
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/

EXPOSE 5432

VOLUME  ['/scripts', '/opt/log', '/opt/etc', '/opt/data']

CMD ["/bin/bash", "/scripts/start.sh"]
